namespace Ds.DataBase.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _20200807002 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.KaoHeFanWei_RenYuan", "JiaoZhiGongInfo_zgid", "dbo.JiaoZhiGongInfoes");
            DropIndex("dbo.KaoHeFanWei_RenYuan", new[] { "JiaoZhiGongInfo_zgid" });
            CreateTable(
                "dbo.KaoHeFanWei_RenYuanJiaoZhiGongInfo",
                c => new
                    {
                        KaoHeFanWei_RenYuan_khfwryid = c.Int(nullable: false),
                        JiaoZhiGongInfo_zgid = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.KaoHeFanWei_RenYuan_khfwryid, t.JiaoZhiGongInfo_zgid })
                .ForeignKey("dbo.KaoHeFanWei_RenYuan", t => t.KaoHeFanWei_RenYuan_khfwryid, cascadeDelete: true)
                .ForeignKey("dbo.JiaoZhiGongInfoes", t => t.JiaoZhiGongInfo_zgid, cascadeDelete: true)
                .Index(t => t.KaoHeFanWei_RenYuan_khfwryid)
                .Index(t => t.JiaoZhiGongInfo_zgid);
            
            AddColumn("dbo.NeiRongs", "mbid", c => c.Int(nullable: false));
            AddColumn("dbo.NeiRongs", "mbmc", c => c.String());
            AddColumn("dbo.NeiRongs", "KaoHeFanWei_RenYuan_khfwryid", c => c.Int());
            CreateIndex("dbo.NeiRongs", "KaoHeFanWei_RenYuan_khfwryid");
            AddForeignKey("dbo.NeiRongs", "KaoHeFanWei_RenYuan_khfwryid", "dbo.KaoHeFanWei_RenYuan", "khfwryid");
            DropColumn("dbo.KaoHeFanWei_RenYuan", "JiaoZhiGongInfo_zgid");
        }
        
        public override void Down()
        {
            AddColumn("dbo.KaoHeFanWei_RenYuan", "JiaoZhiGongInfo_zgid", c => c.Int());
            DropForeignKey("dbo.NeiRongs", "KaoHeFanWei_RenYuan_khfwryid", "dbo.KaoHeFanWei_RenYuan");
            DropForeignKey("dbo.KaoHeFanWei_RenYuanJiaoZhiGongInfo", "JiaoZhiGongInfo_zgid", "dbo.JiaoZhiGongInfoes");
            DropForeignKey("dbo.KaoHeFanWei_RenYuanJiaoZhiGongInfo", "KaoHeFanWei_RenYuan_khfwryid", "dbo.KaoHeFanWei_RenYuan");
            DropIndex("dbo.KaoHeFanWei_RenYuanJiaoZhiGongInfo", new[] { "JiaoZhiGongInfo_zgid" });
            DropIndex("dbo.KaoHeFanWei_RenYuanJiaoZhiGongInfo", new[] { "KaoHeFanWei_RenYuan_khfwryid" });
            DropIndex("dbo.NeiRongs", new[] { "KaoHeFanWei_RenYuan_khfwryid" });
            DropColumn("dbo.NeiRongs", "KaoHeFanWei_RenYuan_khfwryid");
            DropColumn("dbo.NeiRongs", "mbmc");
            DropColumn("dbo.NeiRongs", "mbid");
            DropTable("dbo.KaoHeFanWei_RenYuanJiaoZhiGongInfo");
            CreateIndex("dbo.KaoHeFanWei_RenYuan", "JiaoZhiGongInfo_zgid");
            AddForeignKey("dbo.KaoHeFanWei_RenYuan", "JiaoZhiGongInfo_zgid", "dbo.JiaoZhiGongInfoes", "zgid");
        }
    }
}
